<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="会议室名称">
              <a-input placeholder="请输入会议室名称" v-model="queryParam.roomName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus" :disabled="isDisabledAuth('erpMeetingRoom:add')">新增</a-button>
      <!--<a-button type="primary" icon="download" @click="handleExportXls('会议室信息')" :disabled="isDisabledAuth('erpMeetingRoom:export')">导出</a-button>
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel">
        <a-button type="primary" icon="import" :disabled="isDisabledAuth('erpMeetingRoom:import')">导入</a-button>
      </a-upload>-->
      <!-- 高级查询区域 -->
      <!--<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
      <a-popover title="自定义列" trigger="click" placement="leftBottom">
        <template slot="content">
          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
            <a-row>
              <template v-for="(item) in defColumns">
                <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                  <a-col :span="12"><a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox></a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a style="float: right;"><a-icon type="setting" :style="iconStyle"/></a>
      </a-popover>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:1200}"
        :components="draggableComponent"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">

        <span slot="roomName" slot-scope="text, record">
          <a-tooltip>
            <template slot="title">
              查看会议室详情
            </template>
            <a @click="handleDetail(record)">{{ text }}</a>
          </a-tooltip>
        </span>

        <span slot="roomStatus" slot-scope="text">
          <span v-if="text == 0">可用</span>
          <span v-else>不可用</span>
        </span>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" :disabled="isDisabledAuth('erpMeetingRoom:edit')">编辑</a>
          <a-divider type="vertical"/>
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a :disabled="isDisabledAuth('erpMeetingRoom:delete')">删除</a>
          </a-popconfirm>
        </span>

      </a-table>
    </div>

    <erp-meeting-room-modal ref="modalForm" @ok="modalFormOk"></erp-meeting-room-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ErpMeetingRoomModal from './modules/ErpMeetingRoomModal'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'

export default {
  name: 'ErpMeetingRoomList',
  mixins: [JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
  components: {
    ErpMeetingRoomModal
  },
  data () {
    return {
      description: '会议室信息管理页面',
      // 表头
      columns: [],
      // 列设置
      settingColumns: [],
      // 列定义
      defColumns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '会议室名称',
          align: 'center',
          dataIndex: 'roomName',
          width: 200,
          scopedSlots: { customRender: 'roomName' }
        },
        {
          title: '所在位置',
          align: 'center',
          width: 300,
          dataIndex: 'location'
        },
        {
          title: '会议室状态',
          align: 'center',
          dataIndex: 'roomStatus',
          width: 200,
          scopedSlots: { customRender: 'roomStatus' }
        },
        {
          title: '所属公司',
          align: 'center',
          width: 200,
          dataIndex: 'company_dictText'
        },
        {
          title: '管理员',
          align: 'center',
          width: 200,
          dataIndex: 'administrator_dictText'
        },
        {
          title: '容纳人数',
          align: 'center',
          width: 200,
          dataIndex: 'capacity'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 160,
          scopedSlots: {
          filterDropdown: 'filterDropdown',
          filterIcon: 'filterIcon',
          customRender: 'action' }
        }
      ],
      url: {
        list: '/api/erp/oa/meeting/erpMeetingRoom/list',
        delete: '/api/erp/oa/meeting/erpMeetingRoom/delete',
        deleteBatch: '/api/erp/oa/meeting/erpMeetingRoom/deleteBatch',
        exportXlsUrl: '/api/erp/oa/meeting/erpMeetingRoom/exportXls',
        importExcelUrl: '/api/erp/oa/meeting/erpMeetingRoom/importExcel'
      },
      dictOptions: {},
      superFieldList: []
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    /* importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    } */
  },
  methods: {
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'roomName', text: '会议室名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'location', text: '所在位置', dictCode: '' })
      fieldList.push({ type: 'string', value: 'company', text: '所属公司', dictCode: '' })
      fieldList.push({ type: 'string', value: 'administrator', text: '管理员', dictCode: '' })
      fieldList.push({ type: 'int', value: 'capacity', text: '容纳人数', dictCode: '' })
      fieldList.push({ type: 'int', value: 'roomStatus', text: '会议室状态', dictCode: '' })
      fieldList.push({ type: 'string', value: 'equipment', text: '配套设备', dictCode: '' })
      fieldList.push({ type: 'string', value: 'remark', text: '备注', dictCode: '' })
      fieldList.push({ type: 'string', value: 'attachment', text: '附件信息', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
